package com.atguigu.juc.locks;

import java.util.concurrent.TimeUnit;

class Phone8{
    public static synchronized void sengEmail(){
        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + "正在发邮件...");
    }
    public  synchronized void sengSMS(){
        System.out.println(Thread.currentThread().getName() + "正在发短信...");
    }
}

public class Lock8_8 {
    public static void main(String[] args) {
        Phone8 phone8 = new Phone8();
        Phone8 phone8_2 = new Phone8();

        new Thread(()->{phone8.sengEmail();},"t1").start();

        try {
            TimeUnit.MILLISECONDS.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        new Thread(()->{phone8_2.sengSMS();},"t2").start();
    }
}
